/*
 * @Author: c
 * @Date: 2023-12-03 00:54:37
 * @LastEditTime: 2023-12-26 22:08:34
 * @LastEditors: c
 * @Description: 
 * @FilePath: \music-web-backend\src\auth\jwt.strategy.ts
 * https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// import { User } from 'src/user/entities/user.entity';
import { UserService } from '../user/user.service';
import { ExtractJwt, Strategy } from 'passport-jwt';
import { PassportStrategy } from '@nestjs/passport';
import { Injectable } from '@nestjs/common';
import { jwtConstants } from './constants';
import { User } from 'src/core/system/user/entities/user.entity';

@Injectable()
export class JwtStrategy extends PassportStrategy(Strategy) {
  constructor(private userService: UserService) {
    super({
      jwtFromRequest: ExtractJwt.fromAuthHeaderAsBearerToken(),
      ignoreExpiration: false,
      secretOrKey: jwtConstants.secret,
    });
  }

  async validate(payload: any) {
    
    //查询数据库 获取详细信息
  //  const user: User = await this.userService.findOneByUserName(payload.username)
    return payload;
  }
}